package com.follow.service.impl;

import com.follow.common.PageUtil;
import com.follow.dao.TbUserVOMapper;
import com.follow.pojo.TbDepartment;
import com.follow.pojo.TbUserVO;
import com.follow.service.TbuserVOService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.thymeleaf.expression.Ids;

import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2020/9/24.
 */
@Service
public class TbUserVOServcieImpl implements TbuserVOService {


    @Autowired
    private TbUserVOMapper tbUserVOMapper;

    @Override
    public PageUtil<TbUserVO> selectUserVO(Integer pageNum, Integer pageSize, Integer id, String userId, String userName, String password, Integer roleId, Integer sex, String phone, String mail, Integer departmentId) {

        PageUtil<TbUserVO> pageUtil = new PageUtil<>();
        Integer count = tbUserVOMapper.selectUserCount(id,userId,userName,password,roleId,sex,phone,mail,departmentId);
        pageUtil.setTotal(count);
        pageUtil.setPageNum(pageNum);
        pageUtil.setPageSize(pageSize);
        List<TbUserVO> tbUserVOS = tbUserVOMapper.selectUserAll(pageUtil.getStartNum(),pageSize,id,userId,userName,password,roleId,sex,phone,mail,departmentId);
        pageUtil.setResult(tbUserVOS);
        return pageUtil;
    }

    public TbUserVO selectOne(Integer id){
        return tbUserVOMapper.selectOne(id);
    }

    public List<TbDepartment> selectDepartment(){
        return tbUserVOMapper.selectDepartment();
    }

    public boolean addDoctor(String userId, String userName, Integer sex,Integer age,Date birthday,String phone, String mail, String password, Integer roleId, Integer departmentId){
        int i = tbUserVOMapper.addDoctor(userId,userName,sex,age,birthday,phone,mail,password,roleId,departmentId);
        if(i>0) return true;
        else return false;
    }

    public boolean updateOne(TbUserVO tbUserVO){
        int i = tbUserVOMapper.updateOne(tbUserVO);
        if(i>0) return true;
        else return false;
    }

    public boolean removeBeach(String[] ids){
        int i =tbUserVOMapper.removeBeach(ids);
        if(i>0) return true;
        else return false;
    }
}
